import React from "react"

class Demo extends React.Component {
    state = {
        arr: [{
            id: 1,
            title: "新闻"
        }, {
            id: 2,
            title: "体育"
        }, {
            id: 3,
            title: "电影"
        }]
    }

    handle = (item, ev) => {
        console.log(item, ev)
    }

    render() {
        let {arr} = this.state
        return <div>
            {arr.map(item => {
                let {id, title} = item
                return <span key={id} onClick={this.handle.bind(null, item,)}>{title}</span>
            })}
            <button onClick={this.handle}>
                提交
            </button>
        </div>
    }
}

export default Demo